package com.wangsd.web.controller;

import com.wangsd.core.entity.JSONResult;
import com.wangsd.web.model.Billaccount;
import com.wangsd.web.model.Printinfo;
import com.wangsd.web.modelCustom.DataTable;
import com.wangsd.web.modelCustom.HousinginfoCustom;
import com.wangsd.web.modelCustom.PrintInfoCustom;
import com.wangsd.web.modelCustom.UserCustom;
import com.wangsd.web.service.PrintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: qc
 * @Discription:
 * @Date: Create in 16:29 2017/12/8
 */
@RequestMapping("printinfo")
@Controller
public class PrintInfoController {
    @Autowired
    private PrintService printService;

    @RequestMapping("printinfo-list")
    public String printinfoList(){
        return "/printinfo/printinfo-list";
    }


    @RequestMapping("selectAllList")
    @ResponseBody
    public DataTable selectAllList(PrintInfoCustom printInfoCustom) {
        DataTable dataTable = new DataTable();
        List<PrintInfoCustom> printInfoCustoms = printService.selectAllList(printInfoCustom);
        Integer count = printService.selectAllCount(printInfoCustom);
        dataTable.setRecordsFiltered(count);
        dataTable.setRecordsTotal(count);
        dataTable.setData(printInfoCustoms);
        return dataTable;
    }

    @RequestMapping("/deletePrintinfo")
    @ResponseBody
    public JSONResult deletePrintinfo(Integer[] ids) {
        JSONResult jsonResult = new JSONResult();
        for (Integer id : ids) {
             printService.deletePrintinfo(id);
        }
        jsonResult.setMessage("删除成功");
        jsonResult.setSuccess(true);
        return jsonResult;
    }

    @RequestMapping("/deleteStatus")
    @ResponseBody
    public JSONResult deleteStatus(Printinfo printinfo) {
        JSONResult jsonResult = new JSONResult();
        printService.updatePrintinfo(printinfo);
        jsonResult.setSuccess(true);
        return jsonResult;
    }

}
